package remoto;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

import dominio.SolicitudCotizacion;
import dto.SolicitudCotizacionTO;

public class GestionSolicitudesCotizacion {
	private static GestionSolicitudesCotizacion instance;

	public static GestionSolicitudesCotizacion getInstance() throws MalformedURLException, RemoteException, NotBoundException {
		if (instance == null)
			instance = new GestionSolicitudesCotizacion();
		return instance;
	}

	private IGestionSolicitudesCotizacion remoto;

	private GestionSolicitudesCotizacion() throws MalformedURLException, RemoteException, NotBoundException {
		remoto = (IGestionSolicitudesCotizacion) Naming.lookup("GestionSolicitudesCotizacion");
	}

	public int guardarSolicitudCotizacion(SolicitudCotizacion s) throws RemoteException {
		return remoto.guardarSolicitudCotizacion(s.getDTO());
	}

	public SolicitudCotizacion buscarSolicitudCotizacion(int id) throws RemoteException {
		SolicitudCotizacionTO dto = remoto.buscarSolicitudCotizacion(id);
		if (dto != null)
			return SolicitudCotizacion.fromDTO(dto);
		return null;
	}
}